**Replication Materials
**"Inequalities in Place-Based Representation: Looking Inside Electoral Districts", published in European Journal of Political Research
**Authors: Mafalda Pratas (EUI), Jorge M. Fernandes (CSIC); Miguel Won (Lisbon).
**This version: October 8 2024
**Contact: jorge.fernandes@csic.es



* Load dataset
use "Pratas_EJPR_Final.dta", replace

* Graph style
stplot axes, c(mono)

capture: program drop get_range
program define get_range, rclass
syntax varname

quietly: sum `varlist' if e(sample) == 1
_natscale `r(min)' `r(max)' 20

return local min = r(min)
return local max = r(max)
return local delta = r(delta)
end

xtset district_enc

*Main Model

collect clear

label var pop_share_district "Population (% district)"

quietly: collect, tags(model[1]): ///
xtreg recebido_merecido ///
c.pop_share_district##c.pop_share_district i.legislature, ///
fe robust

quietly: collect, tags(model[2]): ///
xtreg recebido_merecido ///
c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
fe robust
estimates store model2

quietly: collect, tags(model[3]): ///
xtreg recebido_merecido ///
c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
fe robust, if municipality != "Lisboa"

quietly: collect, tags(model[4]): ///
jackknife, cluster(district): xtreg recebido_merecido ///
c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
fe robust

quietly: collect, tags(model[5]): ///
jackknife, cluster(municipality): xtreg recebido_merecido ///
c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
fe robust

*Results Table

collect style header result, level(hide)
collect style autolevels result _r_b _r_se

local coefs pop_share_district pop_share_district#pop_share_district magnitude_log turnout income education _cons
collect style autolevels colname `coefs'
collect style cell result, nformat(%9.2f)

collect style cell result[_r_se], sformat("(%s)")
collect stars _r_p 0.05 "*" 0.01 "**" 0.001 "***", attach(_r_b)

collect style header result[N N_clust p], level(label)
collect style cell result[N N_clust], nformat(%9.0f)

collect style cell border_block, border(right, pattern(nil))
collect style cell model, halign(center)

collect label levels result ///
cluster "Cluster", modify

quietly: collect layout (colname#result result[N N_clust p]) (model)

*Appendix

*Appendix F: Party-level Analysis

foreach party in PCP BE PS PSD CDS{
  drop recebido_merecido_`party'
  gen recebido_merecido_`party' = ///
  (mentions_municipality_`party' / mentions_district_`party' * 100) - (pop_share_district)
}

collect clear
foreach party in PCP BE PS PSD CDS{
  quietly collect, tag(party[`party']): xtreg recebido_merecido_`party' ///
  c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
  fe robust
}

*Table F.1

collect style header result, level(hide)
collect style autolevels result _r_b _r_se

local coefs pop_share_district pop_share_district#pop_share_district magnitude_log turnout income education _cons
collect style autolevels colname `coefs'
collect style cell result, nformat(%9.2f)

collect style cell result[_r_se], sformat("(%s)")
collect stars _r_p 0.05 "*" 0.01 "**" 0.001 "***", attach(_r_b)

collect style header result[N N_clust p], level(label)
collect style cell result[N N_clust], nformat(%9.0f)

collect style cell border_block, border(right, pattern(nil))
collect style cell party, halign(center)

collect label levels result ///
cluster "Cluster", modify

quietly: collect layout (colname#result result[N N_clust p]) (party)


*Appendix H: Population Density

collect clear

label var pop_share_district "Population (% district)"

quietly: collect, tags(model[1]): ///
xtreg recebido_merecido ///
c.pop_density##c.pop_density i.legislature, ///
fe robust

quietly: collect, tags(model[2]): ///
xtreg recebido_merecido ///
c.pop_density##c.pop_density magnitude_log turnout income education i.legislature, ///
fe robust
estimates store model2

quietly: collect, tags(model[3]): ///
xtreg recebido_merecido /// 
c.pop_density##c.pop_density magnitude_log turnout income education i.legislature, ///
fe robust, if municipality != "Lisboa"

quietly: collect, tags(model[4]): ///
jackknife, cluster(district): xtreg recebido_merecido ///
c.pop_density##c.pop_density magnitude_log turnout income education i.legislature, ///
fe robust

quietly: collect, tags(model[5]): ///
jackknife, cluster(municipality): xtreg recebido_merecido ///
c.pop_density##c.pop_density magnitude_log turnout income education i.legislature, ///
fe robust

*Table H.1

collect style header result, level(hide)
collect style autolevels result _r_b _r_se

local coefs pop_density pop_density#pop_density magnitude_log turnout income education _cons
collect style autolevels colname `coefs'
collect style cell result, nformat(%9.3f)

collect style cell result[_r_se], sformat("(%s)")
collect stars _r_p 0.05 "*" 0.01 "**" 0.001 "***", attach(_r_b)

collect style header result[N N_clust p], level(label)
collect style cell result[N N_clust], nformat(%9.0f)

collect style cell border_block, border(right, pattern(nil))
collect style cell model, halign(center)

collect label levels result ///
cluster "Cluster", modify

quietly: collect layout (colname#result result[N N_clust p]) (model)

*Appendix I: Dependent variable as a ratio

gen ratio_district = mentions_share_district / pop_share_district * 100
gen ratio_national = mentions_share_national / pop_share_national * 100

collect clear

label var pop_share_district "Population (% district)"

quietly: collect, tags(model[1]): ///
xtreg ratio_district ///
c.pop_share_district##c.pop_share_district i.legislature, ///
fe robust

quietly: collect, tags(model[2]): ///
xtreg ratio_district ///
c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
fe robust
estimates store model2

quietly: collect, tags(model[3]): ///
xtreg ratio_district ///
c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
fe robust, if municipality != "Lisboa"

quietly: collect, tags(model[4]): ///
jackknife, cluster(district): xtreg ratio_district ///
c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
fe robust

quietly: collect, tags(model[5]): ///
jackknife, cluster(municipality): xtreg ratio_district ///
c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature, ///
fe robust

*Table I.1 

collect style header result, level(hide)
collect style autolevels result _r_b _r_se

local coefs pop_share_district pop_share_district#pop_share_district magnitude_log turnout income education _cons
collect style autolevels colname `coefs'
collect style cell result, nformat(%9.2f)

collect style cell result[_r_se], sformat("(%s)")
collect stars _r_p 0.05 "*" 0.01 "**" 0.001 "***", attach(_r_b)

collect style header result[N N_clust p], level(label)
collect style cell result[N N_clust], nformat(%9.0f)

collect style cell border_block, border(right, pattern(nil))
collect style cell model, halign(center)

collect label levels result ///
cluster "Cluster", modify

quietly: collect layout (colname#result result[N N_clust p]) (model)

*Appendix J: Measurement at the national level

gen recebido_merecido_nacional = (mentions_share_national - pop_share_national)

collect, tag(model[national]): xtreg recebido_merecido_nacional ///
c.pop_share_national##c.pop_share_national magnitude_log turnout income education i.legislature, ///
fe robust


*Appendix K: Sensitivity Analysis
*Figure K.1
sensemakr recebido_merecido c.pop_share_district##c.pop_share_district magnitude_log turnout income education i.legislature i.district_enc, treat(pop_share_district) benchmark(education) contourplot

graph display 

*Figure K.2

sensemakr recebido_merecido pop_share_district test magnitude_log turnout income education i.legislature i.district_enc, treat(test) benchmark(education) contourplot

graph display











